package com.sdhs.costcontrol.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sdhs.common.annotation.Log;
import com.sdhs.common.core.controller.BaseController;
import com.sdhs.common.core.domain.AjaxResult;
import com.sdhs.common.enums.BusinessType;
import com.sdhs.costcontrol.domain.GcControlChangeManageList;
import com.sdhs.costcontrol.service.IGcControlChangeManageListService;
import com.sdhs.common.utils.poi.ExcelUtil;
import com.sdhs.common.core.page.TableDataInfo;

/**
 * 变更清单管理Controller
 *
 * @author andong
 * @date 2025-03-29
 */
@RestController
@RequestMapping("/costcontrol/manageList")
public class GcControlChangeManageListController extends BaseController
{
    @Autowired
    private IGcControlChangeManageListService gcControlChangeManageListService;

    /**
     * 查询变更清单管理列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:manageList:list')")
    @GetMapping("/list")
    public TableDataInfo list(GcControlChangeManageList gcControlChangeManageList)
    {
        startPage();
        List<GcControlChangeManageList> list = gcControlChangeManageListService.selectGcControlChangeManageListList(gcControlChangeManageList);
        return getDataTable(list);
    }

    /**
     * 导出变更清单管理列表
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:manageList:export')")
    @Log(title = "变更清单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GcControlChangeManageList gcControlChangeManageList)
    {
        List<GcControlChangeManageList> list = gcControlChangeManageListService.selectGcControlChangeManageListList(gcControlChangeManageList);
        ExcelUtil<GcControlChangeManageList> util = new ExcelUtil<GcControlChangeManageList>(GcControlChangeManageList.class);
        util.exportExcel(response, list, "变更清单管理数据");
    }

    /**
     * 获取变更清单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:manageList:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gcControlChangeManageListService.selectGcControlChangeManageListById(id));
    }

    /**
     * 新增变更清单管理
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:manageList:add')")
    @Log(title = "变更清单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GcControlChangeManageList gcControlChangeManageList)
    {
        return toAjax(gcControlChangeManageListService.insertGcControlChangeManageList(gcControlChangeManageList));
    }

    /**
     * 修改变更清单管理
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:manageList:edit')")
    @Log(title = "变更清单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GcControlChangeManageList gcControlChangeManageList)
    {
        return toAjax(gcControlChangeManageListService.updateGcControlChangeManageList(gcControlChangeManageList));
    }

    /**
     * 删除变更清单管理
     */
    @PreAuthorize("@ss.hasPermi('costcontrol:manageList:remove')")
    @Log(title = "变更清单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gcControlChangeManageListService.deleteGcControlChangeManageListByIds(ids));
    }
}
